var citydayvideoCheckedItems;
var data_data;
function getcitydayvideoData() {
    
    
    
	var startDate = $("#citydayvideoStartDate").val();
	var endDate = $("#citydayvideoEndDate").val();
    
    
        
    var osID = document.getElementById("citydayvideoOS").options[document.getElementById("citydayvideoOS").selectedIndex].value;
    var typeID = document.getElementById("citydayvideoType").options[document.getElementById("citydayvideoType").selectedIndex].value;
    
   

	$(".citydayvideoChart").html("");
	if (startDate != "" && endDate != "")
	{
		var start = new Date();
		var end = new Date();

		//统计项
		var items = document.getElementsByName("citydayvideoCheckbox");
		citydayvideoCheckedItems = new Array();
		for(var i=0;i<items.length;i++) {
			if (items[i].checked)
			{
				citydayvideoCheckedItems.push(items[i].value);
			}
		}

		if(citydayvideoCheckedItems.length > 0) {


			jQuery('#body-wrapper').showLoading();
			start.setFullYear(startDate.substring(0,4), startDate.substring(5,7)-1, startDate.substring(8,10));
			end.setFullYear(endDate.substring(0,4), endDate.substring(5,7)-1 ,endDate.substring(8,10));

			days = parseInt((end - start)/1000/60/60/24)+1;

			var APIurl = "/client/citydayvideo?staDate="+startDate+"&pd="+days;
	        
            
            if (osID != ""){
				APIurl += "&os="+osID;
            }
			if (typeID != ""){
				APIurl += "&dt="+typeID;
            }
            

			
			$.ajax({
				type: "GET",
				url: APIurl,
				dataType : "json",
				jsonnp: "callback",
				success:function(data,textStatus){ loadcitydayvideoData(data)}
			});
            
            
            $.ajax({
  url: APIurl,
  type: "POST",
  data: "username="+login_username,
success: function(msg){
   //alert('ok');
}
});
            
		}
		else {
			alert("请选择至少一个统计项");
		}

	}
	else {
		alert("请选择时间区域");
	}
}


function getcitydayvideoDatat(zhi,_type,zuobiao) {
    
    
    
	var startDate = $("#citydayvideoStartDate").val();
	var endDate = $("#citydayvideoEndDate").val();
    
    
        
    
    if(_type == "citydayvideoOS"){
        
        var osID = zhi;
        var typeID = document.getElementById("citydayvideoType").options[document.getElementById("citydayvideoType").selectedIndex].value;
        
        
    }else{
        
        
        var osID = document.getElementById("citydayvideoOS").options[document.getElementById("citydayvideoOS").selectedIndex].value;
        var typeID = zhi;
    
    
    }
    
   

	$(".citydayvideoChart").html("");
	if (startDate != "" && endDate != "")
	{
		var start = new Date();
		var end = new Date();

		//统计项
		var items = document.getElementsByName("citydayvideoCheckbox");
		citydayvideoCheckedItems = new Array();
		for(var i=0;i<items.length;i++) {
			if (items[i].checked)
			{
				citydayvideoCheckedItems.push(items[i].value);
			}
		}

		if(citydayvideoCheckedItems.length > 0) {


			jQuery('#body-wrapper').showLoading();
			start.setFullYear(startDate.substring(0,4), startDate.substring(5,7)-1, startDate.substring(8,10));
			end.setFullYear(endDate.substring(0,4), endDate.substring(5,7)-1 ,endDate.substring(8,10));

			days = parseInt((end - start)/1000/60/60/24)+1;

			var APIurl = "/client/citydayvideo?staDate="+startDate+"&pd="+days;
	        
            
            if (osID != ""){
				APIurl += "&os="+osID;
            }
			if (typeID != ""){
				APIurl += "&dt="+typeID;
            }
            

			
			$.ajax({
				type: "GET",
				url: APIurl,
				dataType : "json",
				jsonnp: "callback",
				success:function(data,textStatus){ loadcitydayvideoData(data,zuobiao)}
			});
		}
		else {
			alert("请选择至少一个统计项");
		}

	}
	else {
		alert("请选择时间区域");
	}
}


var citydayvideoTabArr, citydayvideoDetailArr, citydayvideoSumArr, citydayvideoDateArr, MainSubTitle;
function loadcitydayvideoData(data,zuobiao) {
    
    if(!zuobiao){
    
    zuobiao = "All";
}
    
    var osID = document.getElementById("citydayvideoOS").options[document.getElementById("citydayvideoOS").selectedIndex].value;
    var typeID = document.getElementById("citydayvideoType").options[document.getElementById("citydayvideoType").selectedIndex].value;
    
    data_data = data;
	var tab = "";
	var startDate = $("#citydayvideoStartDate").val();
	var endDate = $("#citydayvideoEndDate").val();
	MainSubTitle = startDate.replace(/\//g, "-") + " 至 " + endDate.replace(/\//g, "-");
	jQuery('#body-wrapper').hideLoading();	


	citydayvideoTabArr = new Array();
	citydayvideoDetailArr = new Array();
	citydayvideoSumArr = new Array();
	citydayvideoDateArr = new Array();

			//显示选择Tab
			
            if(osID=="61,52,59"){

            genTabscitydayvideo("citydayvideo", "citydayvideoOS", citydayvideoTabArr, citydayvideoDetailArr, citydayvideoSumArr, citydayvideoCheckedItems,zuobiao);
        }else if(typeID == "1,2"){

            genTabscitydayvideo("citydayvideo", "citydayvideoType", citydayvideoTabArr, citydayvideoDetailArr, citydayvideoSumArr, citydayvideoCheckedItems,zuobiao);
        }else{ genTabscitydayvideo("citydayvideo","", citydayvideoTabArr, citydayvideoDetailArr, citydayvideoSumArr, citydayvideoCheckedItems,zuobiao);  }
        
			
            
            //读取数据
            
        if ($("#citydayvideoPieTab").hasClass("selbitem")){
            
			changeChartType('citydayvideo', 'Pie');
        }
        
        if ($("#citydayvideoTableTab").hasClass("selbitem")){
            
			changeChartType('citydayvideo','Table');
        }
        
        if (!$("#citydayvideoTableTab").hasClass("selbitem") && !$("#citydayvideoPieTab").hasClass("selbitem")){
            
			changeChartType('citydayvideo','Table');
        }
        
        
        
        //生成表格
        genTop10Tablecitydayvideo("citydayvideoTable", valueFullNameArr(citydayvideoCheckedItems), citydayvideoTabArr, data['All']['mtable'], data['All']['gtable']);
        
        //生成饼图
        genzhutucity("citydayvideoPie",data['All']['bingtucityx'],data['All']['bingtucityy'],data['All']['bingtuprovx'],data['All']['bingtuprovy']);
        
		
	
}

function changecityvideoTab(cname){
   
     
    
    $(".cityvideozhuanyong").hide();
    
   
    $("#citydayvideo"+cname).show();
        
            
    $(".bitemvideo").removeClass("selbitem");
	$("#cityvideoTab"+cname).addClass("selbitem");


}

function changecitydayvideoTab(tabName,optionName,zuobiao) {
	
        

        
    getcitydayvideoDatat(tabName,optionName,zuobiao);
    
    
    
	
}



